package cc.siyecao.mapper.conditions;

import cc.siyecao.mapper.enums.SqlOrder;

import java.io.Serializable;

public interface Order<W, R> extends Serializable {

    /**
     * 排序：ORDER BY 字段, ... ASC
     */
    default W orderByAsc(R... columns) {
        return orderBy( true, SqlOrder.ASC, columns );
    }

    /**
     * 排序：ORDER BY 字段, ... ASC
     */
    default W orderByAsc(boolean condition, R... columns) {
        return orderBy( condition, SqlOrder.ASC, columns );
    }

    /**
     * 排序：ORDER BY 字段, ... DESC
     */
    default W orderByDesc(R... columns) {
        return orderBy( true, SqlOrder.DESC, columns );
    }

    /**
     * 排序：ORDER BY 字段, ... DESC
     */
    default W orderByDesc(boolean condition, R... columns) {
        return orderBy( condition, SqlOrder.DESC, columns );
    }

    /**
     * 排序：ORDER BY 字段, ...
     * <p>例: sqlOrder(true, "id")</p>
     *
     * @param sqlOrder 排序
     * @param column   单个字段
     * @return children
     */
    default W orderBy(SqlOrder sqlOrder, R column) {
        return orderBy( true, sqlOrder, column );
    }

    /**
     * 排序：ORDER BY 字段, ...
     * <p>例: sqlOrder(true, "id")</p>
     *
     * @param condition 执行条件
     * @param column    单个字段
     * @param sqlOrder  排序
     * @return children
     */
    W orderBy(boolean condition, SqlOrder sqlOrder, R column);

    /**
     * 排序：ORDER BY 字段, ...
     */
    default W orderBy(SqlOrder sqlOrder, R... columns) {
        return orderBy( true, sqlOrder, columns );
    }

    /**
     * 排序：ORDER BY 字段, ...
     */
    W orderBy(boolean condition, SqlOrder sqlOrder, R... columns);
}
